package com.hhh.petadopt.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hhh.petadopt.pojo.Lost;
import com.hhh.petadopt.pojo.News;
import com.hhh.petadopt.service.IndexService;
/**
 * 首页显示
 * @author 杜镇声声
 *
 */
@Controller
public class IIIdexcontroller {
	
	@Autowired
	private IndexService indexService;
	
	@RequestMapping(value="/index/indexlist.html")
	public String showLogin(Model model) {
		List<Lost> lostLunBo = indexService.LunBoTu();
		//查找热点新闻
		List<News> hotnews = indexService.selecthotNews();
		//查找普通新闻
		List<News> normalList = indexService.selectNormalNews();
		
		//将数据存放到模型中
		model.addAttribute("lostLunBo", lostLunBo);
		model.addAttribute("hotnews", hotnews);
		model.addAttribute("normalList", normalList);
		return "index";
	}
	
	//显示更多热点新闻列表
	@RequestMapping(value="/index/HotNews")
	public String showHotNewsList(Model model) {
		//执行查询
		List<News> newsListt = indexService.selectHotNewsList();
		//将数据存放到模型中
		model.addAttribute("newsListt", newsListt);
		return "newsList";
	}
	//显示更多普通新闻
	@RequestMapping(value="/index/NormalNews")
	public String showNorMalNews(Model model) {
		//执行查询
		List<News> newsListt = indexService.selectMoreNorMalNewsList();
		//将数据存放到模型中
		model.addAttribute("newsListt", newsListt);
		return "newsList";
	}

}
